package cn.ustb.controller;

import cn.ustb.entity.CourseSchedule;
import cn.ustb.entity.User;
import cn.ustb.service.CourseScheduleService;
import cn.ustb.serviceImpl.CourseScheduleServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

/**
 * @author yuyan
 */
@WebServlet("/courseInformationServlet.do")
public class CourseInformationServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获得教师信息，转换到显示页面显示教师信息
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        CourseScheduleService courseScheduleService=new CourseScheduleServiceImpl();
        List<CourseSchedule> courseSchedules=courseScheduleService.getTeacherAllCourse(user.getName());
        request.setAttribute("courseSchedules", courseSchedules);
        request.getRequestDispatcher("/course.jsp").forward(request, response);
    }
}
